package mq

import (
	"fmt"
	"yunpan/cache/log"
)

var done chan bool

func StartConsume(qName, cName string, callback func(msg []byte) bool ) {
	msgs, err := channel.Consume(
		qName,
		cName,
		true,
		false,
		false,
		false,
		nil)
	if err != nil {
		log.Ob().Warn(err.Error())
		return
	}

	done = make(chan bool)

	go func() {
		for msg := range msgs {
			fmt.Println("msg::"+string(msg.Body))
			processSuc := callback(msg.Body)
			if !processSuc {
				log.Ob().Error("callback调用失败")
			}
		}
	}()

	<-done


}